
<template>
    <BaseModal
        :visible="visible"
        title="版本记录"
        :width="1200"
        destroy-on-close
        @cancel="handleModalCancel"
    >
        <s-table
            ref="table"
            row-key="id"
            :columns="columns1"
            :data="loadData"
            :alert="true"
            show-size-changer
            show-quick-jumper
            :show-pagination="false"
            :scroll="{ y: 400 }"
            bordered
        >
            <template slot="operation" slot-scope="text, record" >
                <a @click="handleDetail(record)">查看</a>
            </template>
        </s-table>
        <template slot="footer">
            <a-button @click="handleModalCancel"> 关闭 </a-button>
        </template>
    </BaseModal>
</template>
<script>
import BaseModal from '@/components/BaseModal'
import { columns1 } from '../model.js'
import { queryStagePlanVersionList } from '@/api/project/phasedPlanning'
export default {
  name: 'VersionRecord',
  props: {
    // 隐藏显示
    visible: {
      type: Boolean,
      require: true
    },
    // 版本记录信息
    data: {
      type: Object,
      require: true
    },
    activeKey: {
      type: String,
      require: true
    }
  },
  components: {
        BaseModal
  },
  data() {
    return {
        // 表头
        columns1,
    }
  },
  methods: {
    /**
     * @description: 表格数据加载方法
     * @param {Object} parameter 分页信息
     * @return {Promise} 接口Promise
     */
    async loadData(parameter) {
        try {
            const res = await queryStagePlanVersionList({ stagePlanId: this.data.id })
            return { code: 200, ...res.data.list, data: res.data, }
        } catch (error) {
            return Promise.reject()
        }
    },
    /**
     * @description: 查看详情
     * @param {object} record 行数据
     * @return {void}
     */
    handleDetail(record) {
        const { version } = record
        const { id, code } = this.data
        this.handleModalCancel()
        this.$router.push({
            path: '/project/plannManagement/phasedPlanning/edit',
            query: {
                id,
                type: 'look',
                version,
                activeKey: this.activeKey
            }
        })
    },
    /**
     * @description: 关闭模态框
     * @param {void}
     * @return {void}
     */
    handleModalCancel() {
        this.$emit('update:visible', false)
    }
  }
}
</script>
<style lang="less" scoped>
    @deep: ~'>>>';
    @{deep} .ant-table-fixed {
        margin-left: 0;
    }
</style>
